/**
 * 
 */
package com.qolome.filter;

import static org.springframework.cloud.netflix.zuul.filters.support.FilterConstants.POST_TYPE;
import static org.springframework.cloud.netflix.zuul.filters.support.FilterConstants.SEND_RESPONSE_FILTER_ORDER;

import java.util.UUID;

import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Component;

import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;
import com.netflix.zuul.exception.ZuulException;

/**
 * @Description: 返回过滤
 * @author 姜锋
 * @date 2020年1月24日 下午7:11:56 
 * @version V1.0   
 *
 */
@Component
public class ResponseFilter extends ZuulFilter{
	
	/* （非 Javadoc）
	 * @see com.netflix.zuul.IZuulFilter#shouldFilter()
	 */
	@Override
	public boolean shouldFilter() {
		return false;
	}

	/* （非 Javadoc）
	 * @see com.netflix.zuul.IZuulFilter#run()
	 */
	@Override
	public Object run() throws ZuulException {
		RequestContext currentContext = RequestContext.getCurrentContext();
		 HttpServletResponse response = currentContext.getResponse();
		 response.setHeader("CLOUD-SELL", UUID.randomUUID().toString());
		return null;
	}

	/* （非 Javadoc）
	 * @see com.netflix.zuul.ZuulFilter#filterType()
	 */
	@Override
	public String filterType() {
		return POST_TYPE;
	}

	/* （非 Javadoc）
	 * @see com.netflix.zuul.ZuulFilter#filterOrder()
	 */
	@Override
	public int filterOrder() {
		return SEND_RESPONSE_FILTER_ORDER-1;
	}
}
